<?php
$this->headScript();
$this->headLink();
echo $this->render('resource/advertise/_tab.phtml');
?>
<form action="" method="post" enctype="multipart/form-data"<?php echo ' autocomplete="off"'?>>
<?php echo $this->form()->hidden('referer', $this->referer) . "\n";?>
<div class="body">
	<table class="form">
		<tr>
			<th colspan="2"><?php echo $this->language('ADVERTISEMENT ITEM INFORMATION');?>:</th>
		</tr>
		<tr>
			<td width="180"><label><?php echo $this->language('Name');?></label></td>
			<td><span class="show"><?php echo $this->row->getName();?></span></td>
		</tr>
		<tr>
			<td><label><?php echo $this->language('Dscription');?></label></td>
			<td><?php echo $this->form()->text('description', $this->item->getDescription(), array('size' => '30', 'maxlength' => '100'));?></td>
		</tr>
		<tr>
			<td><label><?php echo $this->language('Is On Layout');?></label></td>
			<td class="radio"><?php echo $this->form()->radio('is_layout', $this->item->getIsLayout(), array('0' => 'No', '1' => 'Yes'));?></td>
		</tr>
		<tr>
			<td><label><span class="red">*</span> <?php echo $this->language('Display On Language');?></label></td>
			<td><ul class="citem"><?php 
			foreach(new system_setting_language() AS $lang) {
				$_name = strtolower($lang->getKey());
				$_disabled = $lang->getEnable() ? '' : ' class="gray"';
				$_checked = '';
				if(in_array($_name, (array) array_keys($this->langs)) && $this->langs[$_name]['checked'] == true) {
					$_checked = ' checked="checked"';
				}
				$stime = isset($this->langs[$_name]) && isset($this->langs[$_name]['start_time']) ? $this->langs[$_name]['start_time'] : time();
				$etime = isset($this->langs[$_name]) && isset($this->langs[$_name]['end_time']) ? $this->langs[$_name]['end_time'] : time() + 86400;
				echo '<li' . $_disabled . '>';
				echo '<input type="checkbox" name="lang[' . $_name . '][checked]" id="lang-' . $_name . '" value="1"' . $_checked . ' />';
				echo '<label class="for-checkbox" for="lang-' . $_name . '">' . $lang->getName() . ' - ' . $lang->getTitle() . ' / <strong>' . $lang->getTimezone() . '</strong></label>';
				echo '<ul class="sub">';
				echo '<li><span class="red">' . $this->language('Start Time') . '</span>' . 
						$this->partial('include/timePicker.phtml', array('name' => 'lang[' . $_name . '][start_time]', 'time' => $stime)) . '</li>';
				echo '<li><span class="red">' . $this->language('End Time') . '</span>' . 
						$this->partial('include/timePicker.phtml', array('name' => 'lang[' . $_name . '][end_time]', 'time' => $etime)) . '</li>';
				echo '</ul>';
				echo '</li>';
			}
			?></ul></td>
		</tr>
		<tr>
			<td><label><span class="red">*</span> <?php echo $this->language('Display On Device');?></label></td>
			<td><ul class="citem"><?php 
			foreach(new system_setting_client() AS $device) {
				$_name = strtolower($device->getKey());
				$_checked = '';
				if(in_array($_name, (array) $this->devices)) {
					$_checked = ' checked="checked"';
				}
				echo '<li>';
				echo '<input type="checkbox" name="device[]" id="device-' . $_name . '" value="' . $_name . '"' . $_checked . ' />';
				echo '<label class="for-checkbox" for="device-' . $_name . '">' . ucfirst($_name) . ' - ' . $device->getTitle() . '</label>';
				echo '</li>';
			}
			?></ul></td>
		</tr>
		<tr>
			<td><label><?php echo $this->language('Display Order');?></label></td>
			<td><?php echo $this->form()->text('display_order', $this->item->getDisplayOrder(), array('size' => '4', 'maxlength' => '4'));?></td>
		</tr>
		<tr>
			<td><label><?php echo $this->language('Javascript Srcs');?></label></td>
			<td>
				<?php echo $this->form()->textarea('script', $this->item->getScript(), array('rows' => '3', 'cols' => '70'));?>
				<code><?php echo $this->language('Separate multiple srcs by ENTER key');?>.</code>
			</td>
		</tr>
		<tr>
			<td><label><?php echo $this->language('Javascript Code');?></label></td>
			<td>
				<?php echo $this->form()->textarea('script_body', $this->item->getScriptBody(), array('rows' => '6', 'cols' => '70'));?>
				<code><?php echo $this->language('Leave it empty if no code');?>.</code>
			</td>
		</tr>
		<tr>
			<td><label><?php echo $this->language('Style Links');?></label></td>
			<td>
				<?php echo $this->form()->textarea('style', $this->item->getStyle(), array('rows' => '3', 'cols' => '70'));?>
				<code><?php echo $this->language('Separate multiple links by ENTER key');?>.</code>
			</td>
		</tr>
		<tr>
			<td><label><?php echo $this->language('Style Code');?></label></td>
			<td>
				<?php echo $this->form()->textarea('style_body', $this->item->getStyleBody(), array('rows' => '6', 'cols' => '70'));?>
				<code><?php echo $this->language('Leave it empty if no code');?>.</code>
			</td>
		</tr>
		<tr>
			<th colspan="2"><?php echo $this->language('DEFAULT SETTING');?>:</th>
		</tr>
		<tr>
			<td><label><?php echo $this->language('Default Resource');?>..</label></td>
			<td>
				<input type="file" name="hash" size="30" />
				<code><?php echo $this->language("Only supports for");?>: <strong><?php echo strtoupper(implode(',', resource_config_advertise::getExtensions()));?></strong></code>
				<?php if($this->item->getResource()->getHash()) { ?>
				<code><a href="<?php echo $this->item->getResource()->getOriginal(false);?>" target="_blank"><?php echo $this->item->getResource()->getOriginal(false);?></a></code>
				<div style="font-weight:bold;padding:5px 0 3px 0;">
					<input type="checkbox" name="deleteResource" id="deleteResource" value="1" />
					<label for="deleteResource" class="for-checkbox"><?php echo $this->language('Delete Resource');?></label>
				</div>
				<?php } ?>
			</td>
		</tr>
		<tr>
			<td><label><?php echo $this->language('Default URL');?></label></td>
			<td><?php echo $this->form()->text('url', $this->item->getUrl(), array('size' => '50'));?></td>
		</tr>
		<tr>
			<td></td>
			<td>
				<button type="submit" name="submit" value="submit"><?php echo $this->language('Submit');?></button>
				<?php
				if($this->item->getId()) {
					echo $this->render('include/deleteButton.phtml');
				}
				?>
			</td>
		</tr>
	</table>
</div>
</form>
